package pub.developers.forum.portal.controller.rest;


import org.springframework.web.bind.annotation.*;
import pub.developers.forum.api.model.ResultModel;
import pub.developers.forum.api.request.config.ConfigQueryRequest;
import pub.developers.forum.api.response.config.ConfigResponse;
import pub.developers.forum.api.service.ConfigApiService;
import pub.developers.forum.common.constant.Constant;
import pub.developers.forum.portal.support.WebUtil;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/config-rest")
public class ConfigRestController {

    @Resource
    private ConfigApiService configApiService;

    //普通用户查询轮播图
    @PostMapping("/queryConfig")
    public ResultModel<List<ConfigResponse>> userQueryConfig(HttpServletRequest request , @RequestBody ConfigQueryRequest configQueryRequest)
    {
        //验证用户登录状态
        request.setAttribute(Constant.REQUEST_HEADER_TOKEN_KEY, WebUtil.cookieGetSid(request));
        return configApiService.userQueryAllArticle(configQueryRequest);
    }
}
